<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="../../static/plugin/layui/css/layui.css" th:href="@{static/plugin/layui/css/layui.css}">
    <script rel="stylesheet" src="../../static/plugin/layui/layui.js" th:src="@{static/plugin/layui/layui.js}"></script>

    <script src="../../static/js/jquery.min.js" th:src="@{/static/js/jquery.min.js}"></script>
</head>
<body style="background: rgb(224,255,251);">
<div style="width: 50%;margin: 80px auto;padding: 20px;opacity:1;border-radius:15px; background: rgb(116,174,118)">
    <form id="form" class="layui-form" action="/add_course" method="post">
<!--        -->
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">课程编号</label>
                <div class="layui-input-inline">
                    <input name="coID" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">学年学期</label>
            <div class="layui-input-inline">
                <select name="scyear">
                    <option value="">请选择学年</option>
                    <option value="2018-2019">2018-2019</option>
                    <option value="2019-2020">2019-2020</option>
                    <option value="2020-2021">2020-2021</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="semester">
                    <option value="">请选择学期</option>
                    <option value="1">第一学期</option>
                    <option value="2">第二学期</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">课程名称</label>
                <div class="layui-input-inline">
                    <input name="coname" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">课程类别</label>
            <div class="layui-input-inline">
                <select name="cotype">
                    <option value="">请选择类别</option>
                    <option value="必修">必修</option>
                    <option value="选修">选修</option>
                    <option value="通识">通识</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">课程学分</label>
                <div class="layui-input-inline">
                    <input name="credit" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">课程课时</label>
                <div class="layui-input-inline">
                    <input name="hour" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn site-login-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <!-- 	  <div class="layui-form-item">
                <div class="layui-inline">
                  <label class="layui-form-label">范围</label>
                  <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="price_min" placeholder="￥" autocomplete="off" class="layui-input">
                  </div>
                  <div class="layui-form-mid">-</div>
                  <div class="layui-input-inline" style="width: 100px;">
                    <input type="text" name="price_max" placeholder="￥" autocomplete="off" class="layui-input">
                  </div>
                </div>
              </div> -->

    </form>
</div>
</body>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert("提交成功！")
            return true;
        });

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function(){
            form.val('example', {
                "username": "贤心" // "name": "value"
                ,"password": "123456"
                ,"interest": 1
                ,"like[write]": true //复选框选中状态
                ,"close": true //开关状态
                ,"sex": "女"
                ,"desc": "我爱 layui"
            });
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function(){
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

    });
</script>
</html>
